<%--
  User: chenjy
  Date: 2018/2/9
  Time: 上午12:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html>
<head>
    <%@include file="../common/includ.jsp" %>
</head>
<body>
<form class="layui-form layui-form-pane" action="">
    <input type="hidden" name="id" value="${user.id }">
    <div class="layui-form-item ">
        <label class="layui-form-label">登录名</label>
        <div class="layui-input-block">
            <input type="text" name="loginName" value="${user.loginName }" required lay-verify="required"
                   placeholder="请输角色数字编号" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <input type="text" name="phone" value="${user.phone }" lay-verify="required|integer"
                       placeholder="请输入手机号"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-hide">
            <button id="submit" class="layui-btn" lay-submit lay-filter="submit">立即提交</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    layui.use(['form', 'layer'], function () {
        var form = layui.form, layer = layui.layer;
        form.verify({
            integer: function (value, item) {
                if (!new RegExp("^[1-9]\\d*$").test(value)) {
                    return '请输入正整数';
                }
            }
        });
        form.on('submit(submit)', function (data) {
            var id = $('form').find('input[name=id]').val();
            var url = ctxAdmin + '/user/save';
            if (id && id > 0)
                url = ctxAdmin + '/user/update';
            addData(url, data.field, 'userTable');
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    })
</script>
</body>
</html>
